package com.cloud.jdkTest;

import org.junit.Test;

public class ThreadTest {
    @Test
    public void interruptTest() throws Exception{
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (ThreadTest.class) {
                    try {
                        ThreadTest.class.wait();
                        System.out.println("thread is awake");
                        for (int i = 0; i < Integer.MAX_VALUE; ++i) {
                            System.out.println(i + "");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        thread.start();
        Thread.sleep(1000);
        System.out.println("thread is going to be interrupted");
        thread.interrupt();
    }
}
